Skip to main content

CNC Example 03: Performing Path Preprocessing Online

See the CNC03_prepro.project sample project in the installation directory of CODESYS under ..\CODESYS SoftMotion\Examples.

The example shows how path preprocessing can be performed online on the PLC.

Extend the CNC02_online project with one path preprocessor. Then the angles of the movement of the CNConline project are rounded by means of splines. This is done with the SMC_SmoothPath function block.

  1. Extend the CNC program: Append the previous program with the elements G51/G50.

    Click CNC → Show preprocessed path so that the splines created by path preprocessing are displayed in the editor, as in the screenshot below.

    Display:

    _sm_img_example_cnc3_1.png
  2. Without using variables, you could compile the program in this form as a queue and enter it directly into the interpolator. However, as variables are available, you have to perform decoding and angle smoothing yourself.

    Declare a new function block of type SMC_SmoothPath. Call it after the decoder.

    Set the data input of the interpolator function block as usual to the poqDataOut output of the CheckVelocities function block.

    A new buffer has to be declared for the input SMC_SmoothPath.pbyBufferOutQueue.

    CFC:

    _sm_img_example_cnc3_2.png

Commissioning

Compile and start the created program. In contrast with the previous program, this program no longer stops at the angles of the NC program because the angles of the path have been made free of kinks by means of the path preprocessing.